<?php
namespace Admin\Controller;
class ResourceController extends CommonController{
	public function index(){
		$this->display();
	}
	
	public function get_videos(){
		$m = D('MaterialVideos');
		$p = I('p') ? I('p') : 1;
		$row = I('row') ? I('row') : 10;
		if(I('condition')) {
            $condition = condition_to_array(I('condition')); //加入条件参数
            foreach($condition as $key=>$val){
                if($key == 'id' || $key == 'status'){
                    $map[$key] = $val;
                }else{
                    $map[$key] = array('like',"%{$val}%");
                }
            }
        }
		$data['data'] = $m->where($map)->page($p,$row)->select();
		$data['page']['total'] = $m->where($map)->count();
		$data['page']['cur'] = $p;
		$data['page']['row'] = $row;
		_apiReturn(1, "success", $data,$url);
	}
	
	public function get_files(){
		$m = D('MaterialFiles');
		$p = I('p') ? I('p') : 1;
		$row = I('row') ? I('row') : 10;
		if(I('condition')) {
            $condition = condition_to_array(I('condition')); //加入条件参数
            foreach($condition as $key=>$val){
                if($key == 'id' || $key == 'status'){
                    $map[$key] = $val;
                }else{
                    $map[$key] = array('like',"%{$val}%");
                }
            }
        }
		$data['data'] = $m->where($map)->where($map)->page($p,$row)->select();
		$data['page']['total'] = $m->count();
		$data['page']['cur'] = $p;
		$data['page']['row'] = $row;
		_apiReturn(1, "success", $data,$url);
	}
	
	public function get_images(){
		$m = D('MaterialImages');
		$p = I('p') ? I('p') : 1;
		$row = I('row') ? I('row') : 10;
		if(I('condition')) {
            $condition = condition_to_array(I('condition')); //加入条件参数
            foreach($condition as $key=>$val){
                if($key == 'id' || $key == 'status'){
                    $map[$key] = $val;
                }else{
                    $map[$key] = array('like',"%{$val}%");
                }
            }
        }
		$data['data'] = $m->where($map)->page($p,$row)->select();
		$data['page']['total'] = $m->where($map)->count();
		$data['page']['cur'] = $p;
		$data['page']['row'] = $row;
		_apiReturn(1, "success", $data,$url);
	}
	
}